﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link  href="../weblib/skins/main.css" rel="stylesheet" type="text/css" />
    <link href="../weblib/jquery.easyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../weblib/jquery.easyui/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../WebFileExplorer/easyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <script src="../webjs/core/config.js" type="text/javascript"></script>
    <script src="../WebFileExplorer/Scripts/jquery-1.6.4.min.js" type="text/javascript"></script>
    <script src="../WebFileExplorer/easyui/jquery.easyui.min.js" type="text/javascript"></script>
     <script src="../weblib/jquery/jquery.adaptor.js" type="text/javascript"></script>
     
     <script type="text/javascript">
         var language = $.cookie('_language_');
         if (language == null || language == '') {
             document.write("<script src='../Language/sys_language/zh.js'><\/script>");
         }
         else if (Number(language) == 1) {
             document.write("<script src='../Language/sys_language/zh.js'><\/script>");
         }
         else if (Number(language) == 0) {
             document.write("<script src='../Language/sys_language/en.js'><\/script>");
         }

   </script>
       
 <style type="text/css" >
     .editable
     {
         display:inline-block; border:0px ;float:left; padding-right:5px; width: 22px;height: 20px;
         background: url('../WebFileExplorer/Scripts/hu8-fileexplorer/images/small/editable_grey.png') no-repeat 
     }
    .editable:hover
    {
         display :inline-block; border:0px ;float:left; padding-right:5px; width: 22px;height: 20px;
         background:url('../WebFileExplorer/Scripts/hu8-fileexplorer/images/small/editable_bule.png') no-repeat
     }
 
    .visible
    {
        display:inline-block; border:0px; float:left; padding-right:5px; width: 22px;height: 20px;
        background: url('../WebFileExplorer/Scripts/hu8-fileexplorer/images/small/visible_grey.png') no-repeat 
    }
    .visible:hover
    {
         display:inline-block; border:0px; float:left; padding-right:5px; width: 22px;height: 20px;
         background:url('../WebFileExplorer/Scripts/hu8-fileexplorer/images/small/visible.png') no-repeat
    }
    .download
    {
          display:inline-block; border:0px ;float:left; padding-right:5px; width: 22px;height: 20px;
          background: url('../WebFileExplorer/Scripts/hu8-fileexplorer/images/small/download_grey.png') no-repeat 
    }
    .download:hover
    {
         display:inline-block; border:0px; float:left; padding-right:5px; width: 22px;height: 20px;
         background:url('../WebFileExplorer/Scripts/hu8-fileexplorer/images/small/download_bule.png') no-repeat
    
    }
 </style>
  <style type="text/css">
        .lines-both .datagrid-body td{
        }
        .lines-no .datagrid-body td{
            border-right:1px dotted transparent;
            border-bottom:1px dotted transparent;
        }
        .lines-right .datagrid-body td{
            border-bottom:1px dotted transparent;
        }
        .lines-bottom .datagrid-body td{
            border-right:1px dotted transparent;
        }
    </style>
 


    <script type="text/javascript">
        var target;
        var isAdmin = $.cookie('isAdmin');

        var user_id = $.cookie('_userId_');
        
//        //判断当前用户是否是项目库管理员
        $(function () {
//            $.ajaxHandler({

            $('#fileList').height($(window).height() - 90);
            $('#fileList').datagrid('getPanel').removeClass('lines-both lines-no lines-right lines-bottom').addClass('lines-bottom');
            target = unescape(getQueryString("target"));
            var bus = unescape(getQueryString("bus"));
            var num = getQueryString("num");
            loadGrid(target, bus);

        });
        function loadGrid(target, bus) {
            //加载数据  
            $('#fileList').datagrid({
                width: 1360,
                height: 570,
                checkOnSelect: true,
                selectOnCheck: true,
                singleSelect: false,
                remoteSort: false,
                onSelect: onSelect,
                onUnselect: onUnselect,
                onSelectAll: onSelectAll,
                onUnselectAll: onUnselectAll,
                
                url: 'AssetsStatistics.aspx?search=1&file=1&target=' + escape(target) + "&bus=" +escape(bus),
                //queryParams:{},  
                loadMsg: 'loading......',
                pagination: true,
                rownumbers: true,
                onLoadSuccess: function (data) {
                    $(".zh_en").each(function () {
                        this.innerHTML = eval($(this).attr('rel'));
                    });
                }
               
            });
        }
        function genButton(val) {
            var strBtn = "";
            if (isAdmin == 1) {
                $("#editlist").show();
                strBtn = "<div class='buttons' style='width:150px;display:none' ><input onclick='edit(" + val + ")' type='button' style='width:25px' class='editable' />"
                strBtn += "<input onclick='browse(" + val + ")' type='button' style='width:25px' class='visible' />";
                strBtn += "<input onclick='download(" + val + ")' type='button' style='width:25px' class='download' /></div>"
            }
            else {
                $("#editlist").hide();
                strBtn = "<div class='buttons' style='width:150px;display:none' ><input onclick='browse(" + val + ")' type='button' style='width:25px' class='visible' />";
                strBtn += "<input onclick='download(" + val + ")' type='button' style='width:25px' class='download' /></div>"
            }
            return strBtn;
           
        }

        function download(strId) {
            $.ajaxHandler({
                url: App_Config.TadongUrl + "/AjaxMappingHandler.aspx",
                urlType: "GetUserFileRoleRight",
                model: function () {
                    var obj = {};
                    obj.UserId = user_id;
                    obj.FileId = strId;
                    obj.SpaceType = "30";
                    obj.OpreType = "30";
                    return $.toJSON(obj);
                },
                success: function (data) {
                    if (data) {
                        var rows = $('#fileList').datagrid('getSelections');
                        for (var i = 0; i < rows.length; i++) {
                            if (rows[i].FILE_ID == strId) {
                                isClickIcon = true;
                                break;
                            }
                        }
                        $("#frame").attr({
                            src: "../Views/DataSearch/WatchFileView.aspx?hiddenDownload=single&id=" + strId + "&space_type=" + '30'
                        });
                    }
                    else
                        alert(lang.Insufficient_permissions_contact_your_administrator);
                }
            });
        }
        function downloadlist(strId) {
            var str = "";
            var rows = $('#fileList').datagrid('getSelections');
            for (var i = 0; i < rows.length; i++) {
                str += rows[i].FILE_ID + ",";
            }
            if (str == "") {
                alert(lang.SPACE_No_data);
                return;
            }
            str = str.substring(0, str.length - 1);
            var strs = str.split(',');
            var strlength = strs.length;

            $.ajaxHandler({
                url: App_Config.TadongUrl + "/AjaxMappingHandler.aspx",
                urlType: "GetUserFileRoleRightList",
                model: function () {
                    var obj = {};
                    obj.UserId = user_id;
                    obj.FileId = str;
                    obj.SpaceType = "30";
                    obj.OpreType = "30";
                    return $.toJSON(obj);
                },
                success: function (data) {
                    var str1 = data;
                    str1 = str1.substring(0, str1.length - 1);
                    var str1_1 = str1.split(',');
                    
                    var strlength1 = str1_1.length;
                    if (strlength1 == strlength) {
                        downloaddatas(str1);
                    } else {
                        if (confirm(lang.Insufficient_permissions_whether_to_continue_to_download)) {
                             downloaddatas(str1);
                        }
                    }
                }
            });

        }

        //批量下载文件
        function downloaddatas(paths) {
            
            $("#frame").attr({
                src: "../Views/DataSearch/WatchFileView.aspx?hiddenDownload=" + paths.toString()
            });
           
        }
        function edit(strId) {
            var rows = $('#fileList').datagrid('getSelections');
            for (var i = 0; i < rows.length; i++) {
                if (rows[i].FILE_ID == strId) {
                    isClickIcon = true;
                    break;
                }
            }
            url = "../WebFileExplorer/DataSubmit/EditSourceFiles2.aspx?path=" + strId + "&filename=" + '' + "&spacetype=project";
            url = App_Config.CurrentUrl + "/WebFileExplorer/DataSubmit/EditSourceFiles2.aspx?path=" + strId + "&filename=" + '' + "&spacetype=project";
            var con = "<iframe style='width:100%;height:100%;border:0;' src='" + url + "'></iframe>";
            $('#win').html(con);
            $('#win').window('open');

        }

        function editlist() {

          var str = "";
          var rows = $('#fileList').datagrid('getSelections');
          for (var i = 0; i < rows.length; i++) {
              str += rows[i].FILE_ID + ","; ;
           }

            if (str == "") {
                alert(lang.SPACE_No_data);
                return;
            }
            str = str.substring(0, str.length - 1);
            var strs = str.split(',');
            var strlength = strs.length;
            if (strlength > 1) {
               alert(lang.SPACE_The_current_view_to_select_more_than_one_file);
                return;
            }
            var strId = strs;
            $.ajaxHandler({
                url: App_Config.TadongUrl + "/AjaxMappingHandler.aspx",
                urlType: "GetUserFileRoleRight",
                model: function () {
                    var obj = {};
                    obj.UserId = user_id;
                    obj.FileId = strId.toString();
                    obj.SpaceType = "30";
                    obj.OpreType = "10";
                    return $.toJSON(obj);
                },
                success: function (data) {
                    if (data) {
                        url = "../WebFileExplorer/DataSubmit/EditSourceFiles2.aspx?path=" + strId + "&filename=" + '' + "&spacetype=project";
                        url = App_Config.CurrentUrl + "/WebFileExplorer/DataSubmit/EditSourceFiles2.aspx?path=" + strId + "&filename=" + '' + "&spacetype=project";
                        var con = "<iframe style='width:100%;height:100%;border:0;' src='" + url + "'></iframe>";
                        $('#win').html(con);
                        $('#win').window('open');

                    }
                    else
                        alert(lang.Insufficient_permissions_contact_your_administrator);
                }
            });
            
        }


        function browse(strId) {
            $.ajaxHandler({
                url: App_Config.TadongUrl + "/AjaxMappingHandler.aspx",
                urlType: "GetUserFileRoleRight",
                   model: function () {
                    var obj = {};
                    obj.UserId = user_id;
                    obj.FileId = strId;
                    obj.SpaceType ="30";
                    obj.OpreType = "10";
                    return $.toJSON(obj);
                },
                success: function (data) {
                    if (data) {
                        // 查看文件是否存在
                        $.post('../Handlers/FileExistHandler.ashx?fileid=' + strId + "&space_type=" +'30',
                        {},
                        function (data) {
                            if (data.success && data.exist) {
                                var rows = $('#fileList').datagrid('getSelections');
                                for (var i = 0; i < rows.length; i++) {
                                    if (rows[i].FILE_ID == strId) {
                                        isClickIcon = true;
                                        break;
                                    }
                                }
                                window.open("../Views/DataSearch/WatchViewHander.aspx?id=" + strId + "&space_type=" + '30', "_blank");
                            }
                            else {
                                alert(lang.File_converting);
                            }

                        });
                        
                    }
                    else
                        alert(lang.Insufficient_permissions_contact_your_administrator);        
                }
            });

        }
        //批量预览
        function browselist() {
            var str = "";
            var rows = $('#fileList').datagrid('getSelections');
            for (var i = 0; i < rows.length; i++) {
                str += rows[i].FILE_ID + ","; 
            }

            if (str == "") {
                alert(lang.SPACE_No_data);
                return;
            }
            str = str.substring(0, str.length - 1);
            var strs = str.split(',');
            var strlength = strs.length;
            if (strlength > 1) {
                alert(lang.SPACE_The_current_view_to_select_more_than_one_file);
                return;
            }
            var strId = strs;
            $.ajaxHandler({
                url: App_Config.TadongUrl + "/AjaxMappingHandler.aspx",
                urlType: "GetUserFileRoleRight",
                model: function () {
                    var obj = {};
                    obj.UserId = user_id;
                    obj.FileId = strId.toString();
                    obj.SpaceType ="30";
                    obj.OpreType = "10";
                    return $.toJSON(obj);
                },
                success: function (data) {
                    if (data) {
                       // 查看文件是否存在
                        $.post('../Handlers/FileExistHandler.ashx?fileid=' + strId + "&space_type=" +'30',
                        {},
                        function (data) {
                            if (data.success && data.exist) {

                                window.open("../Views/DataSearch/WatchViewHander.aspx?id=" + strId + "&space_type=" + '30', "_blank");
                            }
                            else {
                                alert(lang.File_converting);
                            }

                        });
                        
                    }
                    else
                        alert(lang.Insufficient_permissions_contact_your_administrator);
                }
            });
        }
        function getQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }
        var isClickIcon = false;
        function onUnselect(index, row) {
            $($($(".datagrid-view2 .datagrid-btable .datagrid-row")[index]).find('.buttons')[0]).css('display', 'none');
            if (isClickIcon) {
                $('#fileList').datagrid('selectRow', index);
            }

            isClickIcon = false;

        }
        function onSelect(index, row) {

            var len = $(".datagrid-view2 .datagrid-btable .datagrid-row").length;
            for (var i = 0; i < len; i++) {
                $($($(".datagrid-view2 .datagrid-btable .datagrid-row")[i]).find('.buttons')[0]).css('display', 'none');
            }


            // var data = row;  //.css('display','block');
            $($($(".datagrid-view2 .datagrid-btable .datagrid-row")[index]).find('.buttons')[0]).css('display', 'block');

        }
        function onSelectAll(rows) {
            //            for (var i = 0; i < rows.length; i++) {
            //                $($($(".datagrid-view2 .datagrid-btable .datagrid-row")[i]).find('.buttons')[0]).css('display', 'block');
            //            }
        }
        function onUnselectAll(rows) {
            for (var i = 0; i < rows.length; i++) {
                $($($(".datagrid-view2 .datagrid-btable .datagrid-row")[i]).find('.buttons')[0]).css('display', 'none');
            }
        }

    </script>



</head>
<body>
    <div data-options="region:'north',border:false" class="topbg" style="height:80px"><div class="logo"></div>
    <div>
      <div id="rightinfo">
         <div class="top_right_exit"><span title="" onclick="logout();"></span></div>
      </div>
     </div>
     </div>
    <div></div>
    <table id="fileList" class="easyui-datagrid" title="" style="width:700px;height:250px" 
            data-options="rownumbers:true,singleSelect:true,method:'get'">

        <thead>
            <tr>
                <th data-options="field:'ck',checkbox:true"></th>
                <th data-options="field:'FILE_NAME',width:500" sortable="true"><span class="zh_en" rel="lang.file_name""></span></th>
                <th data-options="field:'FILE_ID',width:200,formatter: genButton" >
                     <input id="editlist" onclick='editlist()' type='button' style='width:25px' class='editable' />
                     <input onclick='browselist()' type='button' style='width:25px' class='visible' />
                     <input onclick='downloadlist()' type='button' style='width:25px' class='download' />
                </th>
                <th data-options="field:'FILE_CRT_DATE',width:120" sortable="true"><span class="zh_en" rel="lang.Creation_time"></span></th>
               <!-- <th data-options="field:'DEST_OBJ',width:120">所属目标</th>-->
                
            </tr>
        </thead>
    </table>
    <script type="text/javascript">

        $('#fileList').datagrid('getPanel').removeClass('lines-both lines-no lines-right lines-bottom').addClass('lines-bottom');
        
    </script>

   


    <div title="File List" id="aa">
    </div>
    <iframe id='frame' src="#" style="height: 1px"></iframe>
    <div data-options="modal:true,closed:true" id="win" class="easyui-window" title="Edit" style="width:770px;height:530px">
    </div>

</body>
</html>
